package controller;

import gui.OptionPane;

import java.rmi.RemoteException;

import model.MessageInterface;
import model.UserInterface;

public class Message extends Controller
{
	MessageInterface message;
	
	public Message(MessageInterface message)
	{
		this.message = message;
		
		setView(new view.Message(this, message));
	}

	public void reply(UserInterface to)
	{
		forward(new controller.NewMessage(to));
	}
	
	public void delete()
	{
		if (OptionPane.showConfirm("Are you sure you wish to delete this message?") == 0)
		{
			try
			{
				messageRemote.deleteMessage(message);
			}
			catch (RemoteException e)
			{
				OptionPane.showError("Error", "Something went wrong when trying to delete the message.");
			}
		}
	}
	
	public void back()
	{
		forward(new controller.Inbox());
	}
}
